﻿namespace SH.Common.CommonReturn
{
    public class ApiResult<T>
    {
        //错误类型
        public enum ErrorType
        {
            Service = 1,//服务器
            Request = 2,//请求
        }

        public void Success(T t)
        {
            Code = 200;
            Data = t;
            Msg = "OK";
        }
        public void Success()
        {
            Code = 200;
            //Data = t;
            Msg = "OK";
        }
        public void Error(ErrorType error, string? msg)
        {
            Code = (int)error switch
            {
                1 => 500,
                2 => 400
            };
            Msg = msg;
        }
        public int Code { get; set; }
        public T? Data { get; set; }
        public string? Msg { get; set; }
    }
}
